<?php
/**
 * ShopEx licence
 *
 * @copyright  Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn)
 * @license  http://ecos.shopex.cn/ ShopEx License
 */
 
class b2c_ctl_admin_feedback extends desktop_controller{
//@kim 后台付款人详细信息跳出
    var $workground = 'b2c.workground.member';
    
    public function __construct($app)
    {
        parent::__construct($app);
        header("cache-control: no-store, no-cache, must-revalidate");
    }
    
    function index(){
        $this->finder('b2c_mdl_feedback',array(
        'title'=>app::get('b2c')->_('反馈信息列表'),
        'use_buildin_recycle'=>true,
        'use_buildin_filter'=>true,
		'allow_detail_popup'=>true,
//        'base_filter' =>array('for_comment_id' => 0),
        ));
    }

	public function _views(){
       $mdl_feedback = $this->app->model('feedback');
	   $sub_menu = array(
			0=>array('label'=>app::get('b2c')->_('全部'),'optional'=>false,'filter'=>array()),
            1=>array('label'=>app::get('b2c')->_('未处理'),'optional'=>false,'filter'=>array('state'=>'N')),
            2=>array('label'=>app::get('b2c')->_('已处理'),'optional'=>false,'filter'=>array('state'=>'Y')),
        );
		foreach($sub_menu as $k=>$v){
            if($v['optional']==false){
                $show_menu[$k] = $v;
                if(is_array($v['filter'])){
                    $v['filter'] = array_merge(array('order_refer'=>'local'),$v['filter']);
                }else{
                    $v['filter'] = array('order_refer'=>'local');
                }
                $show_menu[$k]['filter'] = $v['filter']?$v['filter']:null;
                if($k==$_GET['view']){
                    $show_menu[$k]['newcount'] = true;
                    $show_menu[$k]['addon'] = $mdl_feedback->count($v['filter']);
                }
                $show_menu[$k]['href'] = 'index.php?app=b2c&ctl=admin_feedback&act=index&view='.($k).(isset($_GET['optional_view'])?'&optional_view='.$_GET['optional_view'].'&view_from=dashboard':'');
            }elseif(($_GET['view_from']=='dashboard')&&$k==$_GET['view']){
                $show_menu[$k] = $v;
            }
        }
		return $show_menu;
    }

	//对反馈信息的处理状态
	 public function save_state(){
		$msg = "";
		$data = array();
		$id = trim($_POST['id']);
		$state = $_POST['state'];
		$data['state'] = $state;
		$fmodel=$this->app->model("feedback");
		$return = $fmodel->update($data,array('id'=>$id));
		if($return){
			echo 'success';exit;
		}else{
			header('Content-Type:text/jcmd; charset=utf-8');
            echo json_encode(array('error'=>app::get('b2c')->_('请求错误')));exit;
		}
    }
}
